package com.copm.demonstrationsystem.controller.login;

import com.copm.demonstrationsystem.commons.response.ResponseStatus;
import com.copm.demonstrationsystem.config.SystemConfig;
import com.copm.demonstrationsystem.pojo.commons.Conditions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chuyunfei
 * @date: 2018/6/19
 * @description: 用于前端的跳转
 */
@RestController
@RequestMapping("/condition")
@CrossOrigin
public class ConditionController {

    private SystemConfig systemConfig;
    private Conditions conditions = new Conditions();

    @RequestMapping
    public Conditions conditions(){

        return this.conditions;
    }

    @Autowired
    public void setSystemConfig(SystemConfig systemConfig){
        this.systemConfig = systemConfig;
        this.conditions.setFace(
                "http://" + systemConfig.getServerIp() + ":" + systemConfig.getServerPort()
                +"/" + systemConfig.getApplicationName() + "/dist1/dist/index.html");
        this.conditions.setBack(
                "http://" + systemConfig.getServerIp() + ":" + systemConfig.getServerPort()
                        +"/" + systemConfig.getApplicationName() + "/dist2/dist/index.html");
        this.conditions.setMobile(
                "http://" + systemConfig.getServerIp() + ":" + systemConfig.getServerPort()
                        +"/" + systemConfig.getApplicationName() + "/dist3/dist/index.html");
    }
}
